#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@file:open_func.py
@time:2016/11/1 0001 18:16
"""
def open(filename,mode='rb'):
    import __builtin__
    file = __builtin__.open(filename,mode)
    if file.read(5) not in ("GIF87","GIT89"):
        raise IOError, "not a gif file"
    file.seek(0)
    return file
fp = open("samples/sample.gif")
print len(fp.read()),"bytes"

fp = open("samples/sample.jpg")
print len(fp.read()),"bytes"